#ifndef __MYIIC_H
#define __MYIIC_H

#include <stdint.h>

#define IIC_SLAVE_ADDR 0x40 // 本设备的 IIC 地址
#define IIC_BUF_LEN_MAX 16  // IIC 单次通信的数据包最大值

typedef struct
{
  uint8_t flag; // data source. if flag=0, data will be send to master; if flag=1, data came from master.
  uint8_t data;
}iic_byte_t;


void IIC0_Init_Master_Slave(void);
void IIC0_Init_Slave(void);
void IIC1_Init(void);
void IIC2_Init(void);
void IIC3_Init(void);
uint8_t IIC_Register_Read_One_Byte(uint32_t ui32Base, uint16_t target_address, uint16_t data_address);
void IIC_Register_Read_Len_Byte(uint32_t ui32Base, uint16_t target_address, uint16_t data_address, uint8_t len, uint8_t *buf);
void IIC_Register_Write_One_Byte(uint32_t ui32Base, uint16_t target_address, uint16_t data_address, uint8_t data);
void IIC_Register_Write_len_Byte(uint32_t ui32Base, uint16_t target_address, uint16_t data_address, uint8_t len, uint8_t *data);
void IIC_Write_One_Byte(uint32_t ui32Base, uint16_t Device_address, uint8_t data);
uint8_t IIC_Read_One_Byte(uint32_t ui32Base, uint16_t Device_address);
#endif
